/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package hmvictor.jpql.nodes;

import hmvictor.jpql.DriversTopComponent;
import java.awt.event.ActionEvent;
import java.io.File;
import javax.swing.AbstractAction;
import javax.swing.JOptionPane;
import org.openide.nodes.Node;
import org.openide.windows.WindowManager;

/**
 *
 * @author Victor
 */
class RemoveDriverAction extends AbstractAction {
    private final Node node;

    public RemoveDriverAction(Node node) {
        super("Remove");
        this.node = node;
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        if (JOptionPane.showConfirmDialog(WindowManager.getDefault().getMainWindow(), "Are you sure you want to remove this driver?") == JOptionPane.OK_OPTION) {
            File file = node.getLookup().lookup(File.class);
            DriversTopComponent c = (DriversTopComponent) WindowManager.getDefault().findTopComponent("DriversTopComponent");
            c.removeDriver(file);
        }
    }
    
}
